{
 "metadata": {
  "name": "",
  "signature": "sha256:d2a34d685ef22a4384319454dd7f58745c3bbff76d89c589a6a613660b219708"
 },
 "nbformat": 3,
 "nbformat_minor": 0,
 "worksheets": [
  {
   "cells": [
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import os\n",
      "import copy\n",
      "from numpy import abs\n",
      "\n",
      "import pyNastran\n",
      "pkg_path = pyNastran.__path__[0]\n",
      "\n",
      "from pyNastran.utils import print_bad_path\n",
      "from pyNastran.op2.op2 import OP2\n",
      "from pyNastran.utils import object_methods, object_attributes\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 6
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# define the object\n",
      "# define the input file using the GUI\n",
      "op2_gui = OP2()\n",
      "op2_gui.read_op2()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "ename": "AssertionError",
       "evalue": "None",
       "output_type": "pyerr",
       "traceback": [
        "\u001b[1;31m---------------------------------------------------------------------------\u001b[0m\n\u001b[1;31mAssertionError\u001b[0m                            Traceback (most recent call last)",
        "\u001b[1;32m<ipython-input-8-5938f102dfac>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m()\u001b[0m\n\u001b[0;32m      2\u001b[0m \u001b[1;31m# define the input file using the GUI\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m      3\u001b[0m \u001b[0mop2_gui\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mOP2\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m----> 4\u001b[1;33m \u001b[0mop2_gui\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0mread_op2\u001b[0m\u001b[1;33m(\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m",
        "\u001b[1;32mc:\\nasa\\m4\\formats\\pynastran_v0.7\\pyNastran\\op2\\op2.pyc\u001b[0m in \u001b[0;36mread_op2\u001b[1;34m(self, op2_filename)\u001b[0m\n\u001b[0;32m    449\u001b[0m             \u001b[0mtitle\u001b[0m \u001b[1;33m=\u001b[0m \u001b[1;34m'Please select a OP2 to load'\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    450\u001b[0m             \u001b[0mop2_filename\u001b[0m \u001b[1;33m=\u001b[0m \u001b[0mload_file_dialog\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mtitle\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mwildcard_wx\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mwildcard_qt\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m--> 451\u001b[1;33m             \u001b[1;32massert\u001b[0m \u001b[0mop2_filename\u001b[0m \u001b[1;32mis\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mNone\u001b[0m\u001b[1;33m,\u001b[0m \u001b[0mop2_filename\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m    452\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m    453\u001b[0m         \u001b[1;32mif\u001b[0m \u001b[1;32mnot\u001b[0m \u001b[0mis_binary\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0mop2_filename\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m:\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
        "\u001b[1;31mAssertionError\u001b[0m: None"
       ]
      }
     ],
     "prompt_number": 8
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "#op2_filename = r'D:\\work\\pynastran_0.7.0_py27\\models\\iSat\\ISat_Launch_Sm_Rgd.op2'\n",
      "#op2_filename = r'D:\\work\\pynastran_0.7.0_py27\\models\\iSat\\ISat_Launch_Sm_4pt.op2'\n",
      "op2_filename = os.path.abspath(os.path.join(pkg_path, '..', 'models', 'iSat', 'ISat_Launch_Sm_4pt.op2'))\n",
      "assert os.path.exists(op2_filename), print_bad_path(op2_filename)\n",
      "\n",
      "# define the input file with a file path\n",
      "op2 = OP2()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [],
     "prompt_number": 10
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# read the op2\n",
      "op2.read_op2(op2_filename)"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "metadata": {},
       "output_type": "pyout",
       "prompt_number": 11,
       "text": [
        "['GEOM1',\n",
        " 'GEOM2',\n",
        " 'GEOM4',\n",
        " 'EPT',\n",
        " 'MPTS',\n",
        " 'DYNAMICS',\n",
        " 'OUGV1',\n",
        " 'OEF1X',\n",
        " 'OES1X1']"
       ]
      }
     ],
     "prompt_number": 11
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "print op2.get_op2_stats()"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "op2.eigenvectors[1]\n",
        "  type=Eigenvector ntimes=167 ngrids=5379\n",
        "  translations, rotations, gridTypes\n",
        "  modes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167]\n",
        "eigrs = [2757.895751953125, 3568.135986328125, 9686.1884765625, 16154.8212890625, 16277.9814453125, 16668.708984375, 18248.4921875, 18591.63671875, 18617.25390625, 31941.08203125, 34933.98828125, 40398.03125, 105008.7734375, 109650.6796875, 113132.6328125, 113452.421875, 135065.921875, 150334.171875, 174828.875, 190511.328125, 247263.609375, 248143.765625, 249965.0625, 252641.453125, 267358.46875, 304008.84375, 309014.46875, 318438.625, 338565.28125, 351562.875, 352142.5625, 384596.4375, 385292.1875, 412883.3125, 420803.1875, 506141.09375, 512093.4375, 550447.4375, 582285.1875, 596320.0625, 619492.4375, 635656.375, 714533.625, 717138.875, 789258.0625, 789476.8125, 812667.8125, 829758.625, 836560.875, 845340.125, 845480.875, 921841.25, 963763.6875, 966138.6875, 972040.5625, 976769.25, 1009583.5625, 1012155.6875, 1070493.875, 1091504.375, 1180308.625, 1300223.125, 1373967.75, 1443581.875, 1481970.75, 1556274.125, 1564383.875, 1608944.0, 1620584.625, 1680112.875, 1756365.875, 1856927.875, 1872126.125, 1881246.375, 1891905.875, 1898146.125, 1927499.125, 2005625.375, 2015030.375, 2024489.375, 2058723.75, 2086919.75, 2292276.25, 2377601.75, 2411275.25, 2465905.0, 2572223.75, 2628440.25, 2658697.0, 2710866.25, 2746213.75, 2771100.25, 2798177.75, 2813809.75, 2835751.75, 2904842.5, 2907620.75, 2940572.75, 2952325.75, 2999655.0, 3014211.75, 3091793.5, 3156497.5, 3274113.0, 3316722.25, 3335977.0, 3442247.75, 3481244.5, 3519034.0, 3552202.0, 3559618.5, 3568005.5, 3666521.5, 3710735.25, 3811038.0, 3823744.25, 3836552.0, 3841662.5, 3870521.25, 3914867.25, 3982016.75, 4066024.5, 4070877.75, 4122935.0, 4126467.5, 4221192.0, 4229641.0, 4256011.0, 4260633.5, 4313936.0, 4333984.5, 4451747.0, 4475993.5, 4484877.5, 4520981.5, 4567997.0, 4571887.0, 4706792.0, 4741043.5, 4823977.5, 4918528.5, 4957954.0, 5091365.5, 5100135.0, 5104857.0, 5111415.0, 5254366.5, 5338743.0, 5373314.0, 5398579.5, 5540606.5, 5585602.5, 5691630.0, 5692052.5, 5697376.5, 5722091.0, 5737279.5, 5782437.0, 5860846.5, 5920603.5, 6020617.5, 6035178.0, 6037030.0, 6102521.0, 6162773.5, 6169898.5, 6229583.0]\n",
        "mode_cycles = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
        "\n",
        "op2.plateStress[1]\n",
        "modes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167]\n",
        "eigrs = [2757.895751953125, 3568.135986328125, 9686.1884765625, 16154.8212890625, 16277.9814453125, 16668.708984375, 18248.4921875, 18591.63671875, 18617.25390625, 31941.08203125, 34933.98828125, 40398.03125, 105008.7734375, 109650.6796875, 113132.6328125, 113452.421875, 135065.921875, 150334.171875, 174828.875, 190511.328125, 247263.609375, 248143.765625, 249965.0625, 252641.453125, 267358.46875, 304008.84375, 309014.46875, 318438.625, 338565.28125, 351562.875, 352142.5625, 384596.4375, 385292.1875, 412883.3125, 420803.1875, 506141.09375, 512093.4375, 550447.4375, 582285.1875, 596320.0625, 619492.4375, 635656.375, 714533.625, 717138.875, 789258.0625, 789476.8125, 812667.8125, 829758.625, 836560.875, 845340.125, 845480.875, 921841.25, 963763.6875, 966138.6875, 972040.5625, 976769.25, 1009583.5625, 1012155.6875, 1070493.875, 1091504.375, 1180308.625, 1300223.125, 1373967.75, 1443581.875, 1481970.75, 1556274.125, 1564383.875, 1608944.0, 1620584.625, 1680112.875, 1756365.875, 1856927.875, 1872126.125, 1881246.375, 1891905.875, 1898146.125, 1927499.125, 2005625.375, 2015030.375, 2024489.375, 2058723.75, 2086919.75, 2292276.25, 2377601.75, 2411275.25, 2465905.0, 2572223.75, 2628440.25, 2658697.0, 2710866.25, 2746213.75, 2771100.25, 2798177.75, 2813809.75, 2835751.75, 2904842.5, 2907620.75, 2940572.75, 2952325.75, 2999655.0, 3014211.75, 3091793.5, 3156497.5, 3274113.0, 3316722.25, 3335977.0, 3442247.75, 3481244.5, 3519034.0, 3552202.0, 3559618.5, 3568005.5, 3666521.5, 3710735.25, 3811038.0, 3823744.25, 3836552.0, 3841662.5, 3870521.25, 3914867.25, 3982016.75, 4066024.5, 4070877.75, 4122935.0, 4126467.5, 4221192.0, 4229641.0, 4256011.0, 4260633.5, 4313936.0, 4333984.5, 4451747.0, 4475993.5, 4484877.5, 4520981.5, 4567997.0, 4571887.0, 4706792.0, 4741043.5, 4823977.5, 4918528.5, 4957954.0, 5091365.5, 5100135.0, 5104857.0, 5111415.0, 5254366.5, 5338743.0, 5373314.0, 5398579.5, 5540606.5, 5585602.5, 5691630.0, 5692052.5, 5697376.5, 5722091.0, 5737279.5, 5782437.0, 5860846.5, 5920603.5, 6020617.5, 6035178.0, 6037030.0, 6102521.0, 6162773.5, 6169898.5, 6229583.0]\n",
        "mode2s = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]\n",
        "cycles = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]\n",
        "  type=RealPlateStress ntimes=167 nelements=4612\n",
        "  eType, fiberCurvature, oxx, oyy, txy, angle, majorP, minorP, ovmShear\n",
        "\n",
        "op2.barForces[1]\n",
        "modes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167]\n",
        "eigrs = [2757.895751953125, 3568.135986328125, 9686.1884765625, 16154.8212890625, 16277.9814453125, 16668.708984375, 18248.4921875, 18591.63671875, 18617.25390625, 31941.08203125, 34933.98828125, 40398.03125, 105008.7734375, 109650.6796875, 113132.6328125, 113452.421875, 135065.921875, 150334.171875, 174828.875, 190511.328125, 247263.609375, 248143.765625, 249965.0625, 252641.453125, 267358.46875, 304008.84375, 309014.46875, 318438.625, 338565.28125, 351562.875, 352142.5625, 384596.4375, 385292.1875, 412883.3125, 420803.1875, 506141.09375, 512093.4375, 550447.4375, 582285.1875, 596320.0625, 619492.4375, 635656.375, 714533.625, 717138.875, 789258.0625, 789476.8125, 812667.8125, 829758.625, 836560.875, 845340.125, 845480.875, 921841.25, 963763.6875, 966138.6875, 972040.5625, 976769.25, 1009583.5625, 1012155.6875, 1070493.875, 1091504.375, 1180308.625, 1300223.125, 1373967.75, 1443581.875, 1481970.75, 1556274.125, 1564383.875, 1608944.0, 1620584.625, 1680112.875, 1756365.875, 1856927.875, 1872126.125, 1881246.375, 1891905.875, 1898146.125, 1927499.125, 2005625.375, 2015030.375, 2024489.375, 2058723.75, 2086919.75, 2292276.25, 2377601.75, 2411275.25, 2465905.0, 2572223.75, 2628440.25, 2658697.0, 2710866.25, 2746213.75, 2771100.25, 2798177.75, 2813809.75, 2835751.75, 2904842.5, 2907620.75, 2940572.75, 2952325.75, 2999655.0, 3014211.75, 3091793.5, 3156497.5, 3274113.0, 3316722.25, 3335977.0, 3442247.75, 3481244.5, 3519034.0, 3552202.0, 3559618.5, 3568005.5, 3666521.5, 3710735.25, 3811038.0, 3823744.25, 3836552.0, 3841662.5, 3870521.25, 3914867.25, 3982016.75, 4066024.5, 4070877.75, 4122935.0, 4126467.5, 4221192.0, 4229641.0, 4256011.0, 4260633.5, 4313936.0, 4333984.5, 4451747.0, 4475993.5, 4484877.5, 4520981.5, 4567997.0, 4571887.0, 4706792.0, 4741043.5, 4823977.5, 4918528.5, 4957954.0, 5091365.5, 5100135.0, 5104857.0, 5111415.0, 5254366.5, 5338743.0, 5373314.0, 5398579.5, 5540606.5, 5585602.5, 5691630.0, 5692052.5, 5697376.5, 5722091.0, 5737279.5, 5782437.0, 5860846.5, 5920603.5, 6020617.5, 6035178.0, 6037030.0, 6102521.0, 6162773.5, 6169898.5, 6229583.0]\n",
        "  type=RealCBarForce ntimes=167 nelements=827\n",
        "  bendingMomentA, bendingMomentB, shear, axial, torque\n",
        "\n",
        "\n"
       ]
      }
     ],
     "prompt_number": 18
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# what modes did we analyze:  1 to 167\n",
      "print \"loadcases =\", op2.eigenvectors.keys()\n",
      "\n",
      "# get subcase 1\n",
      "eig1 = op2.eigenvectors[1]\n",
      "\n",
      "modes = eig1.translations.keys()\n",
      "\n",
      "print \"modes =\", modes, '\\n'\n",
      "\n",
      "mode2 = eig1.translations[2]\n",
      "mode2_node10 = mode2[10]\n",
      "print \"translation mode2_node10 =\", mode2_node10\n",
      "print \"rotations mode2_node10 =\", eig1.rotations[2][10]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "loadcases = [1]\n",
        "modes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167] \n",
        "\n",
        "translation mode2_node10 = [  1.69552350e-05   7.93729909e-03   1.50962302e-03]\n",
        "rotations mode2_node10 = [ -2.24097050e-04   1.22839128e-06  -1.18710750e-06]\n"
       ]
      }
     ],
     "prompt_number": 19
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "plate_stress = op2.plateStress[1]\n",
      "print \"plate_stress_obj =\", type(plate_stress), '\\n'\n",
      "\n",
      "# the set of variables in the PlateStressObject\n",
      "print \"plate_stress = \", plate_stress.__dict__.keys(), '\\n'\n",
      "\n",
      "# list of parameters that define the object (e.g. what is the nonlinear variable name\n",
      "print \"data_code_keys = \", plate_stress.data_code.keys(), '\\n'\n",
      "\n",
      "# nonlinear variable name\n",
      "name = plate_stress.data_code['name']\n",
      "print \"name = %r\" % plate_stress.data_code['name']\n",
      "\n",
      "print \"list-type variables =\", plate_stress.data_code['dataNames']\n",
      "\n",
      "# the special loop parameter\n",
      "# for modal analysis, it's \"modes\"\n",
      "# for transient, it's \"dts\"\n",
      "print \"modes = \", plate_stress.modes # name + 's'\n",
      "\n",
      "\n",
      "# extra list-type parameter for modal analysis; see dataNames\n",
      "#print \"mode_cycles =\", plate_stress.mode_cycles\n"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "plate_stress_obj = <class 'pyNastran.op2.tables.oes_stressStrain.real.oes_plates.RealPlateStress'> \n",
        "\n",
        "plate_stress =  ['code', 'subtitle', 'Title', 'is_built', 'stress_bits', 'load_set', 'thermal', 's_code', 'txy', 'fiberCurvature', 'isubcase', 'angle', 'element_name', 'add_new_eid', 'mode2', 'oyy', 'minorP', 'isTransient', 'ntotal', 'label', 'add', 'num_wide', 'data_code', 'format_code', 'device_code', 'majorP', 'element_names', 'modes', 'dataNames', 'mode2s', 'eType', 'nonlinear_factor', 'dt', 'cycle', 'addNewNode', 'oxx', 'name', 'eigr', 'analysis_code', 'eigrs', 'table_code', 'element_type', 'table_name', 'mode', 'sort_code', 'cycles', 'ntimes', 'ovmShear'] \n",
        "\n",
        "data_code_keys =  ['subtitle', 'Title', u'stress_bits', u'load_set', u'thermal', u's_code', 'isubcase', u'element_name', u'mode2', 'label', u'num_wide', u'format_code', 'device_code', u'dataNames', 'nonlinear_factor', u'cycle', 'name', u'eigr', 'analysis_code', 'table_code', u'element_type', 'table_name', u'mode', 'sort_code'] \n",
        "\n",
        "name = u'mode'\n",
        "list-type variables = [u'mode', u'eigr', u'mode2', u'cycle']\n",
        "modes =  [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167]\n"
       ]
      }
     ],
     "prompt_number": 20
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "def abs_max_min(vals):\n",
      "    absvals = list(abs(vals))\n",
      "    maxval = max(absvals)\n",
      "    i = absvals.index(maxval)\n",
      "    return vals[i]\n",
      "\n",
      "#print \"attributes =\", object_attributes(plate_stress)\n",
      "print \"methods =\", object_methods(plate_stress)\n",
      "print \"\"\n",
      "if plate_stress.isVonMises():  # True\n",
      "    ovm = plate_stress.ovmShear\n",
      "else:\n",
      "    oMaxShear = plate_stress.ovmShear\n",
      "\n",
      "#ovm.keys()  # modes 1-6\n",
      "#ovm[6].keys()  # elements 1-3277\n",
      "print \"\"\n",
      "print \"[layer1, layer2, ...] =\", ovm[6][1000]['CEN/4'] \n",
      "ovm_mode6_eid1000 = abs_max_min(ovm[6][1000]['CEN/4'])\n",
      "print \"ovm_mode6_eid1000 =\", ovm_mode6_eid1000"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        " methods = ['add', 'addNewNode', 'addNewNodeSort1', 'add_f06_data', 'add_new_eid', 'add_new_eid_sort1', 'add_new_transient', 'add_sort1', 'append_data_member', 'apply_data_code', 'cast_grid_type', 'code_information', 'delete_transient', 'getHeaders', 'getOrderedETypes', 'getUnsteadyValue', 'getVar', 'get_data_code', 'get_element_type', 'get_stats', 'get_transients', 'isCurvature', 'isCurvatureOld', 'isFiberDistance', 'isImaginary', 'isMaxShear', 'isRandomResponse', 'isReal', 'isRealImaginaryOrMagnitudePhase', 'isSortedResponse', 'isStrain', 'isStress', 'isVonMises', 'is_magnitude_phase', 'is_real_imaginary', 'is_sort1', 'is_sort2', 'is_thermal', 'print_data_members', 'print_table_code', 'recast_gridtype_as_string', 'set_data_members', 'set_var', 'start_data_member', 'update_data_code', 'update_dt', 'write_f06']\n",
        "\n",
        "\n",
        "[layer1, layer2, ...] = [1146.9427490234375, 1720.633056640625]\n",
        "ovm_mode6_eid1000 = 1720.63305664\n"
       ]
      }
     ],
     "prompt_number": 30
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "# see the difference between \"transient\"/\"modal\"/\"frequency\"-style results\n",
      "# and \"nodal\"/\"elemental\"-style results\n",
      "\n",
      "imode = 6  # mode 6; could just as easily be dt\n",
      "iele = 10  # element 10\n",
      "inode = 'CEN/4'\n",
      "ilayer = 1\n",
      "\n",
      "# result[imode][ielement][ilayer]\n",
      "print \"ps.modes =\", plate_stress.modes#[imode]\n",
      "print \"ps.cycles =\", plate_stress.cycles#[imode]\n",
      "print \"oxx =\", plate_stress.oxx[imode][iele][inode][ilayer]\n",
      "print \"oyy =\", plate_stress.oyy[imode][iele][inode][ilayer]\n",
      "print \"txy =\", plate_stress.txy[imode][iele][inode][ilayer]\n",
      "print \"omax =\", plate_stress.majorP[imode][iele][inode][ilayer]\n",
      "print \"omin = \", plate_stress.minorP[imode][iele][inode][ilayer]\n",
      "print \"ovm/maxShear =\", plate_stress.ovmShear[imode][iele][inode][ilayer]\n",
      "\n",
      "# result[imode][ielement][inode][ilayer]\n",
      "if plate_stress.isFiberDistance():\n",
      "    print \"fiberDistance =\", plate_stress.fiberCurvature[iele][inode][ilayer]\n",
      "else:\n",
      "    print \"curvature =\", plate_stress.fiberCurvature[iele][inode][ilayer]"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "ps.modes = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167]\n",
        "ps.cycles = [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0]\n",
        "oxx = -18.8725357056\n",
        "oyy = -20.1630306244\n",
        "txy = -8.30984687805\n",
        "omax = -11.1829223633\n",
        "omin =  -27.8526439667\n",
        "ovm/maxShear = 24.2766056061\n",
        "fiberDistance = -0.40000000596\n"
       ]
      }
     ],
     "prompt_number": 36
    },
    {
     "cell_type": "code",
     "collapsed": false,
     "input": [
      "import getpass\n",
      "name = getpass.getuser()\n",
      "os.chdir(os.path.join(r'C:\\Users', name, 'Desktop'))\n",
      "\n",
      "# write the F06 with Real/Imaginary or Magnitude/Phase\n",
      "# only matters for complex results\n",
      "op2.write_f06('isat.f06', is_mag_phase=False, delete_objects=True)\n",
      "\n",
      "!head isat.f06"
     ],
     "language": "python",
     "metadata": {},
     "outputs": [
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "F06:\n",
        "Eigenvector        SUBCASE=1\n",
        "RealCBarForce   SUBCASE=1 - CBAR"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n",
        "RealPlateStress SUBCASE=1 - CQUAD4"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "\n"
       ]
      },
      {
       "output_type": "stream",
       "stream": "stdout",
       "text": [
        "     \n",
        "0                                                                                                            SUBCASE 1\n",
        "      EIGENVALUE =  2.757896E+03\n",
        "          CYCLES =  8.358129E+00         R E A L   E I G E N V E C T O R   N O .          1\n",
        " \n",
        "      POINT ID.   TYPE          T1             T2             T3             R1             R2             R3\n",
        "             1      G     -5.547863E-03   2.133077E-04  -8.469186E-04  -8.399206E-06  -2.506956E-04  -5.261146E-05\n",
        "             2      G     -5.547863E-03   1.080848E-04  -3.455275E-04  -8.399206E-06  -2.506956E-04  -5.261146E-05\n",
        "             3      G     -6.169366E-03   2.295251E-04  -8.457433E-04  -8.882780E-06  -2.506924E-04  -4.657186E-05\n",
        "             4      G     -6.169462E-03   1.295465E-04  -3.468718E-04  -7.731095E-06  -2.506902E-04  -4.712092E-05\n"
       ]
      }
     ],
     "prompt_number": 40
    }
   ],
   "metadata": {}
  }
 ]
}